package com.b2b2c.until;
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

import java.util.Map;
/**
 * 分页
 * @author Administrator
 *
 */
public class AjaxPage
{
	
    private int firstRow; // 起始行数
    private int listRows; // 列表每页显示行数
    private Map<String, String >parameter; // 分页跳转时要带的参数
    private long totalRows; // 总行数
    private int totalPages; // 分页总页面数
    private int rollPage   = 11;// 分页栏每页显示的页数
    private boolean astSuffix = true; // 最后一页是否显示总页数

    private String p = "p"; //分页参数名
    public int getFirstRow() {
		return firstRow;
	}

	public void setFirstRow(int firstRow) {
		this.firstRow = firstRow;
	}

	public int getListRows() {
		return listRows;
	}

	public void setListRows(int listRows) {
		this.listRows = listRows;
	}

	public Map<String, String> getParameter() {
		return parameter;
	}

	public void setParameter(Map<String, String> parameter) {
		this.parameter = parameter;
	}

	public long getTotalRows() {
		return totalRows;
	}

	public void setTotalRows(long totalRows) {
		this.totalRows = totalRows;
	}

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public int getRollPage() {
		return rollPage;
	}

	public void setRollPage(int rollPage) {
		this.rollPage = rollPage;
	}

	public String getP() {
		return p;
	}

	public void setP(String p) {
		this.p = p;
	}

	public int getNowPage() {
		return nowPage;
	}

	public void setNowPage(int nowPage) {
		this.nowPage = nowPage;
	}

	private String url = ""; //当前链接URL
    private int nowPage = 1;

    /**
     * 架构函数
     * @param array totalRows  总的记录数
     * @param array listRows  每页显示记录数
     * @param array parameter  分页跳转的参数
     */
    public AjaxPage(long totalRows, int listRows, Map<String, String >parameter) {
        /* 基础设置 */
        this.totalRows  = totalRows; //设置总记录数
        this.listRows   = listRows;  //设置每页显示行数
        this.parameter  = parameter;
        this.nowPage    = Integer.valueOf(parameter.get(this.p));
        this.nowPage    = this.nowPage > 0 ? this.nowPage : 1;
        this.firstRow   = this.listRows * (this.nowPage - 1);
        this.totalPages = (int) Math.ceil(this.totalRows / this.listRows); //总页数
    }
}
